package qlsl.androiddesign.view.subview.activityview;

import qlsl.androiddesign.activity.subactivity.ExChangeActivity;
import qlsl.androiddesign.adapter.subadapter.CoinOrderAdapter;
import qlsl.androiddesign.entity.otherentity.ShoppingDetail;
import qlsl.androiddesign.http.service.subservice.CoinService;
import qlsl.androiddesign.util.runfeng.ToActivityUtil;
import qlsl.androiddesign.view.subview.activityview.peoplecenterbase.PeopleCenterBaseView;
import android.text.TextUtils;
import android.view.View;
import android.widget.BaseAdapter;

import com.qlsl.androiddesign.kuaiwa.R;

/**
 * 兑换记录<br/>
 * 需要传入的键：<br/>
 * 传入的值类型： <br/>
 * 传入的值含义：<br/>
 * 是否必传 ：
 */
public class ExChangeView extends
		PeopleCenterBaseView<ShoppingDetail, ExChangeActivity> {

	public ExChangeView(ExChangeActivity activity) {
		super(activity);
	}

	protected void initView(View view) {
		super.initView(view);
		setTitle("兑换订单");
		CoinService.queryOrderList(1, this, activity);
	}

	protected void initData() {
		super.initData();
	}

	public void onClick(View view) {
		switch (view.getId()) {
		case R.id.tv_contact:
			doClickPhoneNumberView(view);
			break;
		}
	}

	private void doClickPhoneNumberView(View view) {
		int position = refreshView.getRefreshableView()
				.getPositionForView(view);
		ShoppingDetail item = (ShoppingDetail) refreshView.getAdapter()
				.getItem(position);
		if (!TextUtils.isEmpty(item.getBusinessmobile())) {
			ToActivityUtil  
					.callPhoneActivity(activity, item.getBusinessmobile());
		} else {
			showToast("商家未提供电话号码");
		}
	}

	public BaseAdapter getAdapter() {
		return new CoinOrderAdapter(activity, list);
	}

}
